import {defineStore} from 'pinia'
import {ref} from "vue"

export const useUserStore = defineStore('user', () => {
    const token = ref('')
    const user = ref({})
    const setToken = (newToken) => {
        token.value = newToken
    }
    const removeToken = () => {
        token.value = ''
    }
    const setUser = (newUser) =>{
        user.value = newUser
    }
    const clearUser = () => {
        user.value = ''
    }
    return {
        token,
        user,
        setToken,
        removeToken,
        setUser,
        clearUser
    }
}, {
    persist: true
})
